<template>
	<view>
		<view class="history-detail" >
			<!--左侧图片容器-->
			<view class="history-img-wrap">
				<image :src="baseUrl+history.imgPath" mode="aspectFit"></image>
			</view>
			<!--右侧简介-->
			<view class="history-info-wrap">
				<text class="info-text">果蔬类型：{{history.varietyCode}}</text></br>
				<text class="info-text">成熟数量：{{history.matureCount}}</text></br>
				<text class="info-text">总数量：{{history.totalCount}}</text></br>
				<text class="info-text">成熟度：{{(history.matureCount/history.totalCount)*100}}%</text></br>
				<text class="info-text">记录日期：{{history.createTime}}</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
                baseUrl:uni.$request.baseUrl ,
				historyId:0,
                history:{ }
			};
		},
		/**
		 * 生命周期函数--监听页面加载
		 */
		onLoad: function (options) {
		  this.historyId = options.historyId;
          this.getHistoryById(this.historyId);
          
		},
        methods:{
            async getHistoryById(id) {
                const {
                    data: res
                } = await uni.$request.get('/history/'+id)
                if (res.code == 200) {
                    this.history = res.data
                }
                console.log(this.history);
                
            }
        }
	}
</script>

<style lang="scss">
    .history-detail{
        padding: 20rpx;
        .history-img-wrap{
            display: flex;
            justify-content: center;
            image{
                width:100%;
            }
        }
        .history-info-wrap{
            padding: 50rpx;
        }
    }
</style>
